package com.ksana.core;

import com.ksana.util.ClassUtils;

import java.io.File;
import java.io.InputStream;

public class ClassResource implements Resource {
    private String path;
    private ClassLoader classLoader;

    public ClassResource(String path) {
        this(path, null);
    }

    public ClassResource(String path, ClassLoader classLoader) {
        this.path = path;
        this.classLoader = classLoader == null ? ClassUtils.getDefaultClassLoader() : classLoader;
    }

    @Override
    public InputStream getInputStream() {
        return classLoader.getResourceAsStream(path);
    }
}
